"""


"""
from django.conf import settings
from django.core.files.storage import Storage
from fdfs_client.client import Fdfs_client


class MyStorage(Storage):

    def save(self, name, content, max_length=None):

        client = Fdfs_client(settings.FDFS_CONFIG)

        result = client.upload_by_buffer(content.read())

        # print(result)

        # 'Status': 'Upload successed.
        if result["Status"] == 'Upload successed.':
            img_url = result["Remote file_id"]

            return img_url

        else:
            return None